<?php

namespace Admin\Controller;

use Think\Controller;

class StoreController extends Controller {

    public function __construct() {
        parent::__construct();
        $l = D('Login', 'Logic');
        $re = $l->islogin();
        if (!$re) {
            redirect('/admin/login'); 
        }
        $this->store = new \Home\Logic\StoreLogic();
    }
    
    public function index(){
        $store_name = trim($_GET['store_name']);
        $page = (int) $_GET['p'];
        $list = $this->store->searchStore($store_name,$page);
        $this->assign('page',$list['page']);
        $this->assign('list',$list['list']);
        $this->assign('store_name');
        $this->display('index');
    }
    
    /*更改店面授权状态*/
    public function dispose(){
        $id = (int)$_GET['id'];
        $status = trim($_GET['status']);
        if($status == 'display'){ //意为取消授权
            $re = $this->store->updateStoreStatus($id,0);
        }else{
            $re = $this->store->updateStoreStatus($id,1);  //授权
        }
        if($re == false){
            exit('false');
        }
        exit('true');
    }
    
}